package com.lamatek.tags.google;

import java.io.Serializable;

import javax.servlet.jsp.tagext.TagSupport;

/**
 * GoogleMapDivTag
 * 
 * This tag generates the &lt;div> component that represents the physical map
 * in the JSP page. Developers should not override this class.
 * 
 * @author Tom Cole
 * @version 0.40
 */
public class GoogleMapDivTag extends TagSupport implements Serializable {
    
    String id = null;
    String style = null;
    String css_class = null;
    String scope = "page";
    
    /**
     * Overrides doStartTag() from TagSupport. Developers should not override this method.
     */
    public int doEndTag() {
        if (id != null) {
            Object o;
            if (scope.equalsIgnoreCase("site")) {
                o = pageContext.getSession().getAttribute(id);
            }
            else {
                o = pageContext.getAttribute(id);
            }
            if (o != null) {
                GoogleMapTag map = (GoogleMapTag) o;
                map.generateDivTag(this);
            }
        }
        return EVAL_PAGE;
    }
    /**
     * Sets the id of the map that this &lt;div> tag represents.
     * 
     * @param id The id of a &lt;googlemaps:map> tag.
     */
    public void setId(String id) {
        this.id = id;
    }
    /**
     * This method returns the CSS class used to render this &lt;div>.
     * 
     * @return The css style currently defined.
     */
    public String getCss_class() {
        return css_class;
    }
    /**
     * Sets the CSS class to be used when rendering this &lt;div> tag.
     * 
     * @param css_class The CSS classname to use.
     */
    public void setCss_class(String css_class) {
        this.css_class = css_class;
    }
    /**
     * Returns the currently defined CSS style string for this &lt;div> tag.
     * 
     * @return A CSS style string.
     */
    public String getStyle() {
        return style;
    }
    /**
     * Sets the CSS style string to use when rendering this &lt;div> tag.
     * 
     * @param style A valid CSS style string.
     */
    public void setStyle(String style) {
        this.style = style;
    }
    /**
     * Returns the id of the &lt;googlemaps:map> tag that this &lt;div> renders.
     * 
     * @return A &lt;googlemaps:map> tag id.
     */
    public String getId() {
        return id;
    }
    /**
     * Sets the scope where this &lt;div> should look for it's &lt;googlemaps:map>.
     * Valid values are "site" for session or "page" for pageContext.
     * 
     * @param scope A string (site OR page) that denotes session or pageContext.
     */
    public void setScope(String scope) {
        this.scope = scope;
    }
}
